package com.hjx.movie.core.system.controller.admin;

import com.hjx.movie.common.utils.Result;
import com.hjx.movie.common.utils.ResultType;
import com.hjx.movie.core.system.runner.SystemStaticData;
import com.hjx.movie.core.system.service.admin.IAccountService;
import com.hjx.movie.core.system.service.admin.IUserRoleService;
import com.hjx.movie.core.system.service.admin.IUserService;
import com.hjx.movie.core.system.service.commons.file.FileService;
import com.hjx.movie.core.system.vo.CheckedIdsVO;
import com.hjx.movie.core.system.vo.FileVo;
import com.hjx.movie.core.util.PasswordUtil;
import com.hjx.movie.persistence.system.groups.Update;
import com.hjx.movie.persistence.system.model.IvyAccount;
import com.hjx.movie.persistence.system.model.IvyUser;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Map;

/**
 * <p>Title:</p>
 * <p>Description:</p>
 *
 * @author hjx
 * @date 2021/1/2 - 22:51
 */
@Slf4j
@RestController
@RequestMapping("/account")
public class AccountController {

    @Resource
    IAccountService accountService;

    @Resource
    SystemStaticData staticData;

    @GetMapping("/info")
    public Result findAccountInfo(@RequestParam(value="uid") String uid){
        return  Result.success(accountService.lambdaQuery().eq(IvyAccount::getUserId,Long.valueOf(uid)).one());
    }
    @PostMapping("/addBalance")
    public Result addBalance(@RequestBody IvyAccount account){
        log.debug("接收到的入参为:{}",account);
        if (accountService.addBalance(account)) {
            return Result.success("充值成功");
        }
        return  Result.error(ResultType.USER_INPUT_ERROR,"充值失败");
    }
}
